<?php

	function checkResult($result){
		if(!$result){
	    		die();
		}
	}

	mysql_connect("localhost","akosciak","MojaPtaszek");
	
	mysql_select_db("songbump") or die( "Unable to select database");

	$query = "SELECT * FROM  `Edges`";
	$result = mysql_query($query);
	checkResult($result);

	while ($row = mysql_fetch_assoc($result)){
		$updatedWeight = $row["weight"] - 1;
		$query = "UPDATE Edges SET weight=".$updatedWeight." WHERE Id=".$row["Id"];
		$result = mysql_query($query);
		checkResult($result);
	}
	
?>
